home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Technotools
/
Technotools (Chestnut CD-ROM)(1993).ISO
/
lantools
/
blueprnt
/
bpmount.asm
< prev
next >
Wrap
Assembly Source File
|
1989-11-28
|
12KB
|
435 lines
page 60,132
title BP-LAN Shared Disk Device Driver
;**************************************************************
;* BP-LAN Shared Disk Device Driver (BPMOUNT.ASM,BPMOUNT.SYS) *
;* by Craig Chaiken *
;* November 28, 1989 *
;* *
;* Function: *
;* Allows PC Compatible Client to Access any Block Device *
;* on the Server Computer as if it were a local device. *
;* Command Format: *
;* DEVICE=BPMOUNT.SYS /remote_drive /socket_num *
;* /write_protect_flag /max_sector_size *
;**************************************************************
code segment public 'CODE'
assume cs:code,ds:code,es:code;
org 0
;
;*** Device Driver Header ***
;
header dd -1 ;link to next device (assume this to be the last)
dw 2000h ;device attribute = block device
dw strat ;strategy entry point
dw intr ;interrupt entry point
blkdev db 1 ;one block device
db 'BP' ;indicate that device is a BP-LAN Drive
version db 10h ;BP-LAN Version 1.0
socket_num db ?
local_drive db 3 ;default drive D:
remote_drive db 2 ;default drive C:
write_protect db 0 ;default no write protection
;
rh_ptr dd ? ;Pointer to Request Header
;
;*** MSDOS Command Code Vector Table ***
;
vector_table:
dw init ; 0 = initialize driver
dw media_check ; 1 = media_check on block device
dw build_bpb ; 2 = build BIOS parameter block
dw bad
dw read ; 4 = read from device
dw bad,bad,bad
dw write ; 8 = write to device
dw write_verify ; 9 = write with verify
include bpbioshd.mod
include misc.mod
include console.mod
packet_length dw ?
socket_error db ?
;
;*** Strategy Routine ***
;
strat proc far
mov word ptr cs:[rh_ptr],bx
mov word ptr cs:[rh_ptr+2],es
ret
strat endp
;
;*** Interrupt Routine ***
;
intr proc far
pushf
push ax
; cli ;install local stack
; mov cs:stackseg,ss
; mov cs:stackptr,sp
; mov ax,cs
; mov ss,ax
; mov sp,offset local_stack
; sti
push bx
push cx
push dx
push ds
push es
push di
push si
push bp
mov ax,cs
mov ds,ax
les di,cs:rh_ptr
xor bx,bx
mov bl,es:[di+2] ;jump if legal command number
cmp bx,9
jle intr1
mov ax,3 ;unknown command
jmp short error
intr1:
shl bx,1
mov si,offset vector_table
jmp word ptr cs:[si+bx]
error:
or ax,800Ch
cmp cs:write_protect,0
jz success
and ax,0ff00h ;indicate write protect error
success:
or ax,0100h ;set done bit
les di,cs:rh_ptr
mov es:[di+3],ax ;return status word
pop bp
pop si
pop di
pop es
pop ds
pop dx
pop cx
pop bx
; cli ;restore stack
; mov sp,cs:stackptr
; mov ss,cs:stackseg
; sti
pop ax
popf
ret
intr endp
;
;*** Set Done Status for All Unsupported Command Codes ***
;
bad proc near
xor ax,ax
jmp success
bad endp
;
;*** Media Check -- Assume Network Drive is Fixed Disk ***
;
media_check proc near
mov word ptr packet_length,2
mov packet_buffer,'M'
mov al,remote_drive
mov packet_buffer[1],al
put_packet socket_num,packet_length,offset packet_buffer
get_packet
mov al,packet_buffer[2]
mov byte ptr es:[di+14],al ;media not changed
xor ax,ax
jmp success
media_check endp
;
;*** Build BIOS Parameter Block ***
;
build_bpb proc near
mov word ptr es:[di+18],offset bpb
mov es:[di+20],cs
call getboot ;get drive configuration data
xor ax,ax
jmp success
build_bpb endp
;
;*** Read from Block Device ***
;
read proc near
mov function,0
jmp io
read endp
reasec proc near ;*** Read an Absolute Sector From Hub ***
mov word ptr packet_length,4
mov packet_buffer,'R'
mov al,remote_drive
mov packet_buffer[1],al
mov cx,startsect
mov packet_buffer[2],cl
mov packet_buffer[3],ch
put_packet socket_num,packet_length,offset packet_buffer
get_packet
mov cx,cs:seclen
ret
reasec endp
;
;*** Write to Block Device ***
;
write_verify:
write proc near
cmp cs:write_protect,0
jz write1
jmp error ;write protect error
write1: mov function,1
jmp io
write endp
wrisec proc near
mov packet_buffer,'W'
mov al,remote_drive
mov packet_buffer[1],al
mov cx,startsect
mov packet_buffer[2],cl
mov packet_buffer[3],ch
mov cx,cs:seclen
mov word ptr packet_length,cx
add word ptr packet_length,4
put_packet socket_num,packet_length,offset packet_buffer
ret
wrisec endp
;
;*** Generic Disk I/O Handler ***
;
io proc near
mov ax,es:[di+14] ;Data Transfer Address
mov dtaoff,ax
mov ax,es:[di+16]
mov dtaseg,ax
mov ax,es:[di+18] ;# sectors
mov numsectors,ax
mov ax,es:[di+20] ;starting sector
mov startsect,ax
push es
push di
io1: mov ax,numsectors ;exit if sectors = 0
or ax,ax
jz io5
mov es,dtaseg
mov al,function
or al,al
jnz io2
cmp startsect,0
jnz io4a
call getboot
jmp io3
io4a: call reasec
jmp io3
io2: push cx
push si
push di
mov si,dtaoff
lea di,packet_buffer+4
mov cx,cs:seclen
call essitodi
pop di
pop si
pop cx
call wrisec
jmp io4
io3: pop di
push di
push cx
push si
push di
lea si,packet_buffer+4
mov di,dtaoff
mov es,dtaseg
mov cx,cs:seclen
call sitoesdi
pop di
pop si
pop cx
io4: pop di
push di
dec numsectors
inc startsect
push di
mov di,dtaoff
add di,cs:seclen
mov dtaoff,di
jnc sameseg
mov ax,es
add ax,1000h
mov es,ax
mov dtaseg,ax
sameseg: pop di
jmp io1
io5: pop di
pop es
cmp socket_error,0
jnz io6
call ewrite
jmp success
io6: mov ax,word ptr packet_buffer[2]
call ewrite
jmp error
ewrite: mov al,function
cmp al,1
jnz ewrit1
mov packet_buffer,'T'
mov word ptr packet_length,2
put_packet socket_num,packet_length,offset packet_buffer
ewrit1: ret
io endp
getboot proc near ;*** Get Drive Conf. from Boot Sector ***
push cs
pop ds
mov startsect,0
call reasec
lea di,packet_buffer+4
mov ax,[di+0bh]
mov seclen,ax ;get bytes/sector
mov al,[di+0dh]
mov clulen,al ;get sectors/cluster
mov ax,[di+0eh]
mov numres,ax ;get number of reserved sectors
mov al,[di+10h]
mov numfat,al ;get number of fats
mov ax,[di+11h]
mov numdir,ax ;get number of root dir entries
mov ax,[di+13h]
mov numsec,ax ;get total number of sectors
mov al,[di+15h]
mov medtyp,al ;get media descriptor byte
mov ax,[di+16h]
mov fatlen,ax ;get sectors/fat
ret
getboot endp
;
;*** BPB ***
;
bpb_vec dw offset bpb
bpb: ;Sample Values, Replaced by Getboot Procedure
seclen dw 512 ;Bytes/Cluster
clulen db 1 ;Sectors/Cluster
numres dw 1 ;Reserved Sectors
numfat db 2 ;Number of FATs
numdir dw 0e0h ;Number of Directory Entries
numsec dw 960h ;Number of Sectors
medtyp db 0f9h ;Media Type
fatlen dw 7 ;Sectors/FAT
;
;*** Variables ***
;
function db ?
startsect dw ?
numsectors dw ?
dtaseg dw ?
dtaoff dw ?
stackptr dw ?
stackseg dw ?
;
;*** Local Stack ***
;
even
dw 3fh dup (?)
local_stack dw ?
packet_buffer db ?
;
;*** Messages ***
;
mess1 db 'Mounting Server Drive ',0
mess2 db ': as Client Drive ',0
;
;*** initialize ***
;
init proc near
push di
push si
push ds
push di
lea di,mess1
call messout
pop di
mov ax,es:[di+20]
mov ds,ax
mov si,es:[di+18]
call wslash
call charout
sub al,41h
mov cs:remote_drive,al
push di
push ds
push cs
pop ds
lea di,mess2
call messout
pop ds
pop di
mov al,es:[di+22]
mov cs:local_drive,al
add al,41h
call charout
mov al,':'
call charout
mov al,13
call charout
mov al,10
push cx
call charout
call get_opt
jb default
mov cs:socket_num,cl
call get_opt
jb default
mov cs:write_protect,cl
call get_opt
jb default
mov cs:seclen,cx
default:pop cx
pop ds
pop si
pop di
mov byte ptr es:[di+13],1 ;# units
mov word ptr es:[di+14],offset packet_buffer ;break address
mov ax,cs:seclen
add ax,16
add word ptr es:[di+14],ax ;allocate space for buffer
mov word ptr es:[di+16],cs
mov word ptr es:[di+18],offset bpb_vec
mov es:[di+20],cs
jmp success
init endp
code ends
end